from Zk.Zk3.Config.Config import Config
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
import time
class Page(Config):
    # CSS选择器定位用户登录按钮
    denglu_loc=(By.CSS_SELECTOR,'.link-login')
    def denglu(self):
        self.click(self.denglu_loc)
    # XPath定位商品搜索输入框
    srk_loc=(By.XPATH,'//*[@id="key"]')
    # 输入智能手机
    def srk(self):
        self.send_keys(self.srk_loc,'智能手机')
    # 点击搜索按钮
    button_loc=(By.CLASS_NAME,'button')
    def button(self):
        self.click(self.button_loc)
    # //*[@id="searchCenter"]/div/div/div[2]/div[1]
    # 排序
    paixu_loc=(By.XPATH,'//*[@id="shortcut-2014"]/div/ul[2]/li[3]/div/a')
    def paixu(self):
        self.click(self.paixu_loc)

    ymbt_loc=(By.XPATH,'//*[@id="searchCenter"]/div/div/div[2]/div[1]')
    def ymbt(self):
        self.text(self.ymbt_loc)

    # 用户a16524

    def test_jingdong(self):
        # time.sleep(5)
        # self.denglu()
        time.sleep(3)
        self.srk()
        self.button()
        # 强制等待
        time.sleep(20)
        self.jietu()
        time.sleep(3)
        ddt=self.ymbt()
        for i in ddt:
            print(i.text)
            assert "智能手机" in i.text
        time.sleep(3)








